package com.gem.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class SpringMvcConfig implements WebMvcConfigurer {

    @Autowired
    private Interceptor interceptor;

    // 这个方法用来注册拦截器，我们自己写好的拦截器需要通过这里添加注册才能生效
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(interceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/member/**", "/")
                .excludePathPatterns("/m_member/**", "/")
                .excludePathPatterns("/factory/**", "/")
                .excludePathPatterns("/m")
                .excludePathPatterns("/asserts/**")
                .excludePathPatterns("/factory/**");
    }

    /**
     * 配置默认跳转功能
     */
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
//        手机端
        registry.addViewController("/m").setViewName("member/mobile_login");
        registry.addViewController("/mobile_welcome").setViewName("mobile_welcome");

//        PC端
        registry.addViewController("/").setViewName("member/login");
        registry.addViewController("/starter").setViewName("starter");


        registry.addViewController("/welcome").setViewName("welcome");
        registry.addViewController("/home").setViewName("welcome");

        /**院校模块*/
        registry.addViewController("/campusInsert").setViewName("info_insert");

        /**报表*/
        registry.addViewController("/market").setViewName("campus/echart_market");
        registry.addViewController("/leader").setViewName("campus/echart_leader");
        registry.addViewController("/student").setViewName("campus/echart_student");
        registry.addViewController("/course").setViewName("campus/echart_course");
        registry.addViewController("/lecture").setViewName("campus/echart_lecture");
        registry.addViewController("/QQ").setViewName("campus/echart_QQ");
        registry.addViewController("/winter").setViewName("campus/echart_winter");
        registry.addViewController("/summer").setViewName("campus/echart_summer");
        registry.addViewController("/visit").setViewName("campus/visit_echarts");

        /**系统管理模块*/
        registry.addViewController("/member/member_insert").setViewName("system/member_insert");
        registry.addViewController("/member/members").setViewName("system/members");
        registry.addViewController("/member/member_update").setViewName("system/member_update");




    }


}